@extends('admin.public.admin')
@section('main')

<link rel="stylesheet" type="text/css" href="/up/uploadify.css">

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>

<script type="text/javascript" src="/up/jquery.uploadify.min.js"></script>
<!-- 内容 -->
<div class="mws-panel grid_8">
    <div class="mws-panel-header">
         <span>修改广告</span>
    </div>

      <div class="mws-panel-body no-padding">

           <form class="mws-form" action="/admin/sys/ads/{{$data['id']}}" method="post" enctype='multipart/form-data'>
           {{csrf_field()}}
				<input type="hidden" value="PUT" name="_method">
                <div class="mws-form-inline">

                     <div class="mws-form-row">
                          <label class="mws-form-label">标题</label>
                          <div class="mws-form-item">
                               <input type="text" class="small" name="title" value="{{$data['title']}}">
                          </div>
                     </div>

                     <div class="mws-form-row">
                          <label class="mws-form-label">链接</label>
                          <div class="mws-form-item">
                               <input type="text" class="small" name="href" value="{{$data['href']}}">
                          </div>
                     </div>

                     <div class="mws-form-row">
                          <label class="mws-form-label">排序</label>
                          <div class="mws-form-item">
                               <input type="number" class="small" name="sort" value="{{$data['sort']}}">
                          </div>
                     </div>
					

                   
                   	 
          <div class="mws-form-row">
							<label class="mws-form-label">广告图片</label>

                			<div class="mws-form-item">
           
							           <input type="file" name="" id="uploads">
                      
                      </div>
                           
    						<div id="main" class="mws-form-item">
                				 <img width="200px"  src="{{$data['img']}}" alt="">
    						</div>
    						<input type="hidden" name="img" id="imgs">
          </div>
	
          
                  @if($data['status'])
                     <div class="mws-form-row">
                          <label class="mws-form-label">状态</label>
                          <div class="mws-form-item clearfix">
                               <ul class="mws-form-list inline">
                                    <li><input type="radio" name="status" value="1" checked> <label>启用</label></li>
                                    <li><input type="radio" name="status" value="0" > <label>禁用</label></li>                                       
                               </ul>
                          </div>
                     </div>
                  @else

                     <div class="mws-form-row">
                          <label class="mws-form-label">状态</label>
                          <div class="mws-form-item clearfix">
                               <ul class="mws-form-list inline">
                                    <li><input type="radio" name="status" value="1"  > <label>启用</label></li>
                                    <li><input type="radio" name="status" value="0" checked> <label>禁用</label></li>                                       
                               </ul>
                          </div>
                     </div>
                  @endif
                </div>
                <div class="mws-button-row">
                     <input type="submit" value="修改" class="btn btn-danger">
                     <input type="button" class="btn btn-danger" onclick="history.go(-1)" value="返回">

                </div>
           </form>
      </div>         
  </div>

<script>
	$(function() {
		// 声明字符串

		var imgs="";
		// 使用 uploadify 插件
        $('#uploads').uploadify({
        	// 设置文本
            'buttonText' : '广告图片',
            // 设置文件传输数据
            'formData'     : {
            	'_token':'{{ csrf_token() }}',
            	'files':'ads',
                
            },
            // 上传的flash动画
            'swf'      : "/up/uploadify.swf",
            // 文件上传的地址
            'uploader' : "/admin/shangchuan",
            // 当文件上传成功
            'onUploadSuccess' : function(file, data, response) {

            	// // 拼接图片
            	imgs="<img width='200px' src='/Uploads/ads/"+data+ "'>";

            	
            	// 展示图片
            	$("#main").html(imgs);
            	// 隐藏传递数据
            	$("#imgs").val(data);
               
            }
        });
    });
</script>


@endsection